package com.obtk.shilipai.controller;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.obtk.shilipai.entity.Dishe;
import com.obtk.shilipai.entity.Order;
import com.obtk.shilipai.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.annotation.Resource;
import java.util.List;

@Controller
@RequestMapping("/order")
public class OrderController {
    @Autowired
    private OrderService orderService;

    @RequestMapping("/getOrder")
    public String getOrder(@RequestParam(required = false, defaultValue = "1") int pageNo,
                           @RequestParam(required = false, defaultValue = "10") int pageSize,
                           Model model,Integer shopId){
        PageHelper.startPage(pageNo, pageSize);
        List<Order> order = orderService.getOrderByAll(shopId);
        System.out.println(order);
        PageInfo<Order> page = new PageInfo<Order>(order);
        model.addAttribute("page",page);
        model.addAttribute("shopId",shopId);
        model.addAttribute("order",order);
        return "order/list";
    }
}
